package gold.digger;

import gold.vo.TreeNode;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by fanzhenyu02 on 2020/6/27.
 * common problem solver template.
 */
public class LC404 {
    public long startExecuteTime = System.currentTimeMillis();


    class Solution {
        public int sumOfLeftLeaves(TreeNode root) {
            return sumOfLeftLeavesRecur(root, -1);
        }

        public int sumOfLeftLeavesRecur(TreeNode root, int pos) {
            if (null == root) return 0;
            if (null == root.left && null == root.right && 0 == pos) return root.val;//叶子节点
            return sumOfLeftLeavesRecur(root.left, 0) + sumOfLeftLeavesRecur(root.right, 1);
        }
    }

    public void run() {
        Solution solution = new Solution();
        List<Integer> list = new ArrayList<>();
        System.out.println(solution.toString());
    }

    public static void main(String[] args) throws Exception {
        LC404 an = new LC404();
        an.run();

        System.out.println("\ncurrent solution total execute time: " + (System.currentTimeMillis() - an.startExecuteTime) + " ms.");
    }
}
